package com.ibeeking.found.uaa.open.controller.v1;

import com.ibeeking.found.common.config.secret.RsaConfig;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import com.ibeeking.nematos.utils.encryption.EncryptUtils;
import com.ibeeking.nematos.utils.result.ResponseResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @ClassName UserController控制器
 * @Description 全局用户管理
 * @Author ibeeking
 * @Date 2020-12-02 15:29
 **/
@RestController
@RequestMapping("/uaa/v1")
public class OpenUaaController {

    @Resource
    private RsaConfig rsaConfig;

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "公钥查询")
    @GetMapping(value = "/oauth/publicKey")
    public ResponseResult<String> publicKey() {
        return ResponseResult.success(EncryptUtils.RsaEncrypt.getPublicKey(rsaConfig.getKeyPair().getPublic()));
    }
}
